import GameModel from "./GameModel";
import SettingModel from "./SettingModel";

const { ccclass, property } = cc._decorator;

@ccclass
export default class Model extends cc.Component {
    public static game: GameModel = new GameModel()
    public static setting: SettingModel = new SettingModel();

    public static loadData() {
        Model.game.readDraw()

        var dropStr = cc.sys.localStorage.getItem('dropLevel')
        if (!Model.isNull(dropStr)) {
            Model.game.dropLevel = parseInt(dropStr);
        }
        var dragStr = cc.sys.localStorage.getItem('dragLevel')
        if (!Model.isNull(dragStr)) {
            Model.game.dragLevel = parseInt(dragStr);
        }
        var preciseLevelStr = cc.sys.localStorage.getItem('preciseLevel')
        if (!Model.isNull(preciseLevelStr)) {
            Model.game.preciseLevel = parseInt(preciseLevelStr);
        }
    }
    public static isNull(str) {
        if (str != null && str != undefined && str != '' && str != NaN) {
            return false
        }
        return true
    }
}
